from google.appengine.ext import db
from django.utils.translation import ugettext_lazy as _

class Choice(db.Model):
    """A possible answer for a Poll. A Choice has a Poll as its parent."""
    #XX Use a class with multilingual properties which relates to this one
    #through a reference property, and which contains properties which are
    #modified only at creation time, so as to not run into too meny problems
    #due to the limitations of transactions.
    #XX The class can be created automatically the list of multilingual
    #properties.
    #XX Add a lang_code property to know the language in which multilingual
    #properties where originally stored, as to keep track of "lost in translation"
    #issues.
    #XX Localize the count and last_modified through the multilingual classes
    #multilingual = ('choice',)
    
    choice = db.StringProperty(_('Choice'),
        required=True,
        indexed=False)
    
    votes = db.IntegerProperty(_('Votes'),
        default=0,
        required=True,
        indexed=False)

    last_vote = db.DateTimeProperty(_('Last Vote'),
        indexed=False)
    
    #XX In the future, get rid of last_vote, and
    # add a time distribution, location distribution
    # and language distribution. Include the data for
    # such distribution in a child not in the model.
    # Do the same with Poll.

    def __unicode__(self):
        return self.choice